<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>系统登录 - 超市账单管理系统</title>
    <link rel="stylesheet" href="css/style.css"/>
</head>
<body class="login_bg">
    <section class="loginBox">
        <header class="loginHeader">
            <h1>超市账单管理系统</h1>
        </header>
        <section class="loginCont">
            <form class="loginForm">
                <div class="inputbox">
                    <label for="user">用户名：</label>
                    <input id="user" type="text" name="username" placeholder="请输入用户名" required/>
                </div>
                <div class="inputbox">
                    <label for="mima">密码：</label>
                    <input id="mima" type="password" name="password" placeholder="请输入密码" required/>
                </div>
                <div class="subBtn">
                    <input type="button" value="登录" />
                    <input type="reset" value="重置"/>
                </div>

            </form>
        </section>
    </section>

</body>
</html>
<script src="js/jquery.js"></script>
<script src="js/common.js"></script>
<script>
    $(function () {
        $("input[type='button']").click(function(){
            var username = $("#user").val();
            var password = $("#mima").val();

            ajaxtemplate("/smbms/user/dologin",
                {"userCode":username,"password":password},
                "post",
                "json",
                function (data) {
                 // console.log(data);
                    if(data.success){
                        var userCode=data.datas;
                        sessionStorage.setItem("loginuser",userCode);  //保存用户名到浏览器
                        location.href="welcome.html";
                    }else{
                        alert("用戶名或者密碼有誤，請查證后輸入");
                    }
                }
            )
        });
    })

</script>